<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        table{
            border-collapse: collapse;
        }
        table tr td{
            padding: 24px 40px;
        }
        table tr:nth-child(odd){
            background: #aabbcc;
        }
        table tr:nth-child(even){
            background: #ddeeff;
        }
    </style>
</head>
<body>
<table border="1">
    <tr>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td></td>
        <td></td>
    </tr>
    <tr>
        <td></td>
        <td></td>
        <td></td>
    </tr>
</table>

<script>
    let nodes = document.querySelectorAll('td')
    console.log(nodes)
    nodes.forEach(item=>{
        item.onclick = function (){
           item.style.background = '#222'
        }
    })
</script>

</body>
</html>